package com.renting.modules.renting.rentSys.entity;

import java.util.List;

import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;
import com.renting.common.config.CommonConstant;
import com.renting.common.entity.LocationEntity;
import com.renting.modules.sys.entity.Badge;
import com.renting.modules.sys.entity.User;
import org.apache.commons.lang.StringUtils;

@Entity
@Table(name = "RENT_HOUSE")
public class House extends LocationEntity {
    private String acreage;// 面积 单位平方米
    private String address;// 地址
    private Integer total;// 总人数
    private Integer lived;// 已经入住的人数
    private Integer distance;// 存放距离的字段
    private String status = CommonConstant.ACTIVE;// 存放默认为活跃状态
    private Integer price;

    @Transient
    private List<HouseImage> images;


    //查询价格范围
    @Transient
    @JSONField(serialize = false)
    private Integer floorPrice;
    @Transient
    @JSONField(serialize = false)
    private Integer ceilingPrice;
    //排序
    @Transient
    private String orderBy;


    @ManyToMany(cascade = {CascadeType.PERSIST}, fetch = FetchType.EAGER)
    @JoinTable(name = "house_badge", joinColumns = @JoinColumn(name = "house_id", table = "rent_house", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "badge_id", referencedColumnName = "id", table = "sys_badge"))
    private List<Badge> badges;// 标签

    @ManyToOne
    @JoinColumn(name = "contact", referencedColumnName = "id")
    private User contact;// 联系人

    public House(String acreage) {
        this.acreage = acreage;
    }

    public String getAcreage() {
        return acreage;
    }

    public void setAcreage(String acreage) {
        this.acreage = acreage;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getLived() {
        return lived;
    }

    public void setLived(Integer lived) {
        this.lived = lived;
    }

    public Integer getDistance() {
        return distance;
    }

    public void setDistance(Integer distance) {
        this.distance = distance;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public List<HouseImage> getImages() {
        return images;
    }

    public void setImages(List<HouseImage> images) {
        this.images = images;
    }

    public Integer getFloorPrice() {
        return floorPrice;
    }

    public void setFloorPrice(Integer floorPrice) {
        this.floorPrice = floorPrice;
    }

    public Integer getCeilingPrice() {
        return ceilingPrice;
    }

    public void setCeilingPrice(Integer ceilingPrice) {
        this.ceilingPrice = ceilingPrice;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public List<Badge> getBadges() {
        return badges;
    }

    public void setBadges(List<Badge> badges) {
        this.badges = badges;
    }

    public User getContact() {
        return contact;
    }

    public void setContact(User contact) {
        this.contact = contact;
    }

    public House() {
    }
}
